package com.sf.sgs.sessionevaluate.controller;

import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.sf.sgs.sessionevaluate.domain.Test;
import com.sf.sgs.sessionevaluate.service.ITestService;

@Controller
public class TestController {
	private final static Log log = LogFactory.getLog(TestController.class);
	@Autowired
	private ITestService testService;

	@RequestMapping(path = "/index")
	public String index(Map<String, Object> model) {
		log.info("access /index");
		Test test = testService.getById(1L);
		model.put("test", test);
		return "index";
	}
	
	   @RequestMapping(path = "/index/*")
	    public String indexWithId(Map<String, Object> model) {
	        log.info("access /index");
	        Test test = testService.getById(1L);
	        model.put("test", test);
	        return "index";
	    }

	@RequestMapping(path = "/addClass")
	public String addClass(Map<String, Object> model) {
		log.info("access /index");
		Test test = testService.getById(1L);
		model.put("test", test);
		return "addClass";
	}

	@RequestMapping(path = "/testView")
	public ModelAndView testView() {
		Test test = testService.getById(1L);
		ModelAndView modelAndView = new ModelAndView("index", "test", test);
		return modelAndView;
	}

}
